package com.candy.control;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/sessionShow")
public class SessionShowServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        获取Session对象
        HttpSession session=req.getSession();
//        获取session非活动的最大时间
        int time=session.getMaxInactiveInterval();
        System.out.println(time);
//        获取SessionId
        System.out.println(session.getId());
    }
}
